import matplotlib.pyplot as plt
# 使用 for 循环快捷创建对应的列表存储需要的数据
plt.switch_backend('TkAgg') # 设置后端为TkAgg
h, v0, g = 3000, 200, 9.8
t, n = 0, 30
tmax = (2 * h / g) ** 0.5
delta = tmax / (n - 1)
# xt, yt = [], []
# for i in range(n):
#     t = delta * i
#     xt.append(v0 * t)
#     yt.append(h - 1 / 2 * g * t ** 2)
T = [delta * i for i in range(n)]
print(T)
xt = [v0 * t for t in T]
yt = [h - 1 / 2 * g * t ** 2 for t in T]

plt.plot(xt,yt,"ro-")
plt.grid('on')
plt.axis([0, 5000, 0, h])
plt.show()
